Ext.define('Fsl.admin.controller.Navigation', {
	extend      : 'Ext.app.Controller', 
	requires    : Fsl.app.getMergedRequires({
		apps: [],
		misc: []
	}),
	views       : Fsl.view.getViews(['CenterPanel','WestPanel', 'V01I001001:V01I012001']),
	models      : Fsl.model.getModels(['M01I000001','M01I001001:M01I012001']),
	stores      : Fsl.store.getStores(['S01I000000','S01I001001:S01I012001']),
	refs        : [
		{
			ref       : 'activeWindow',
			selector  : 'window'
		}
	],
	init        : function() {        
        this.control({ 
           'westPanel'		: {
                itemclick: this.onItemClick              
            }
        });
    },
	onItemClick : function(view, node){
        if(node.isLeaf()) {
            var leaf   = view.getSelectionModel().getSelection(),
            itemId     = 'id'+leaf[0].data.id,
            TabPanel   = Ext.getCmp('centerPanel'),
            activeTab  = TabPanel.child('#'+itemId),
            component  = leaf[0].data.id.substring(1);
            
            if (activeTab == null){
				switch(component){
					case 'V01I000001': alert('Meta Data' +component);       break;
					case 'V01I001001': Fsl.app.getWidget(component).show(); break;
					case 'V01I002001': Fsl.app.getWidget(component).show(); break;
					case 'V01I003001': Fsl.app.getWidget(component).show(); break;
					case 'V01I004001': Fsl.app.getWidget(component).show(); break;
					case 'V01I005001': Fsl.app.getWidget(component).show(); break;
					case 'V01I006001': Fsl.app.getWidget(component).show(); break;
					case 'V01I007001': Fsl.app.getWidget(component).show(); break;
					case 'V01I008001': Fsl.app.getWidget(component).show(); break;
					case 'V01I009001': Fsl.app.getWidget(component).show(); break;
					case 'V01I010001': Fsl.app.getWidget(component).show(); break;
					case 'V01I011001': Fsl.app.getWidget(component).show(); break;
					case 'V01I012001': Fsl.app.getWidget(component).show(); break;
					default          : alert('Misc' +component);            break;
				}
			}else{
				activeTab.tab.show();
                TabPanel.setActiveTab(activeTab);
			}
		}
	}
});
